export default (
    state = {
        toDoList: [
            { item: "今天心情好，适合敲代码" },
            { item: "2020年9月26日天气阴" }
        ],
        mode: "add",
        visable: false,
    },
    { type, item, index, mode, visable }
) => {
    let toDoList = JSON.parse(JSON.stringify(state.toDoList));
    switch (type) {
        case "ADD":
            toDoList.push({ item });
            return { ...state, toDoList };
        case "DELETE":
            toDoList.splice(index, 1);
            return { ...state, toDoList };
        case "UPDATE":
            toDoList[index] = {item};
            console.log(toDoList)
            return { ...state, toDoList };
        case "MODE": {
            return { ...state, mode };
        }
        case "VISABLE":
            return { ...state, visable };
        default:
            return state;
    }
};
